{extend name="../../base/view/layout" /}
{block name="my_body"}
<div class="maincontent">
    <div class="maincontentinner">

            <table  class="table table-bordered">
                <thead>
                <tr>
                    <?php
                 $count=0;
                 foreach($data as $k=>$v):
                    $count++;
                    ?>
                    <th  ><?php echo $k;?></th>
                    <?php endforeach;?>
                    <th  >库存</th>
                    <th  >商品价格</th>
                    <th  >促销价格</th>
                    <th  >会员价格</th>
                    <th  >商品重量</th>
                    <th  >商品图片</th>
                    <th  >操作</th>
                </tr>
                </thead>
                <tbody>
                <?php if($gnData):
        foreach($gnData as $k0=>$v0):
                ?>
                <tr>
                    <?php foreach($data as $k=>$v):?>
                    <td >
                            <?php foreach($v as $k1=>$v1):
                            $gaid=explode(',',$v0['goods_attr_id']);
                            if(in_array($v1['id'],$gaid))
                            echo $v1['attr_value'];
                            ?>
                            <?php endforeach;?>
                    </td>
                    <?php endforeach;?>
                    <td ><?php echo $v0['goods_number'];?></td>
                    <td ><?php echo $v0['goods_price'];?></td>
                    <td ><?php echo $v0['promote_price'];?></td>
                    <td ><?php echo $v0['member_price'];?></td>
                    <td ><?php echo $v0['goods_weight'];?>&ensp;kg</td>
                    <td ><?php showImage($v0['goods_sm_pic'],30,30);?></td>
                    <td>
                        <a href="<?php echo url('/shop/Goodsattr/goods_num',['goods_id'=>$goods_id,'id'=>$v0['id']]);?>">修改库存/价格</a><br />
                        <a thisid="<?php echo $v0['id'];?>" href="javascript:;" onclick="del(this)">删除</a>
                    </td>
                </tr>
                <!--end-->
                <?php endforeach;?>
                </tbody>
                <?php endif;?>
            </table>


    </div><!--maincontentinner-->
</div><!--maincontent-->
{/block}

{block name="my_js"}
<script>
    function del(t)
    {
        var id = jQuery(t).attr('thisid');
        var url = "<?php echo url('del');?>";
        jQuery.ajax({
            type: 'POST',
            url: url,
            data:"id="+id,
            dataType: 'JSON',
            success: function(res){
                if(res.code == 0)
                {
                    window. location.reload();
                }
                else
                {
                    var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                    var h = jQuery(html);
                    jQuery(".maincontentinner").prepend(h);
                    window.setTimeout(function(){
                        h.remove();
                    },1000);
                }
            }
        })
    }
    </script>

{/block}
